---@diagnostic disable: lowercase-global


local crypt = require "crypt"

function func1()
	local serverkey = crypt.randomkey()
	local clientkey = crypt.randomkey()
	local secret = crypt.dhsecret(serverkey, clientkey)
	local etoken = crypt.desencode(secret, "i'm text i'm text i'm text i'm text")
	local token = crypt.desdecode(secret, etoken)
	print(token)
end

function func2()
	local challenge = crypt.randomkey()                 --1
	local clientkey = crypt.randomkey()
	local exchangeC = crypt.dhexchange(clientkey)       --2
	local serverkey = crypt.randomkey()                 --3
	local exchangeS = crypt.dhexchange(serverkey)       --4

	local secret1 = crypt.dhsecret(exchangeC, serverkey) --5 s
	local secret2 = crypt.dhsecret(exchangeS, clientkey) --5 c
	print(crypt.base64encode(secret1), crypt.base64encode(secret2))
	local etoken = crypt.desencode(secret2, "{i'm text i'm text i'm text i'm text}}}}}}}}")
	local token = crypt.desdecode(secret1, etoken)
	print(token)
end
func1()
func2()
